{% extends 'index.html' %}
{% block ace-content %}
<link rel="stylesheet" href="https://cdn.bootcss.com/ionicons/2.0.1/css/ionicons.min.css">
<link rel="stylesheet" href="/static/dist/css/wiki.css" >
{% endblock %}
{% block page-content %}
<div id="page-wrapper">
<div class="content-body">


        <div class="row">
         <div class="col-lg-12">
              <h1 class="page-header"><i class="fa  fa-book  "></i>  <code>Wiki</code>运维知识</h1>
         </div>         
            <div class="col-md-8" >  
				<article class="post post-{{ article.id }}">
				        <header class="entry-header">
				            <h1 class="entry-title">{{ article.title }}</h1>
				            <div class="entry-meta">
				                <span class="post-category">
				                    <a style="text-decoration:none; color:#404040" href="/wiki/category/{{article.category.id}}">{{ article.category.name }}‧</a></span>
				                <span class="post-date"><a style="text-decoration:none; color:#404040" href="#"><time class="entry-date"
				                                                          datetime="{{ article.created_time }}">{{ article.created_time }}‧</time></a></span>
				                <span class="post-author"><a style="text-decoration:none; color:#404040" href="#"> {{ article.author }}‧</a></span>
				                {% if article.author == user or user.is_superuser %}
				                <span class="post-author"><a style="text-decoration:none; color:#404040" href="/wiki/edit/{{article.id}}"><i class="fa  fa-edit  "></i>‧</a></span>
				                <span class="post-author"><a style="text-decoration:none; color:#404040" href="javascript:void(0);" onclick="delWikiData(this,{{article.id}})"><i class="fa  fa-trash-o  "></i></a></span>
								{% endif %}
				            </div>
				        </header>
				        
				        <div class="entry-content clearfix">
				            {{ article.content|safe }}
				            <legend></legend> 
				            <div class="widget-tag-cloud">
				                <ul>
				                    {% for tag in article.tags.all %}
				                        <li><a style="text-decoration:none; color:#404040" href="/wiki/tag/{{tag.id}}"># {{ tag.name }}</a></li>
				                    {% endfor %}
				                </ul>
				            </div>
				        </div>
				 </article>			        
			               
            </div>
            <div class="col-md-4">
                {% block toc %}
                {% endblock toc %}
                <div class="widget widget-recent-posts">
                    <h3 class="widget-title">最新文章</h3>
                    <ul>
                        {% for post in postList %}
                            <li>
                                <a style="text-decoration:none; color:#404040" href="/wiki/view/{{ post.id }}/">{{ post.title }}</a>
                            </li>
                        {% empty %}
                            暂无文章！
                        {% endfor %}
                    </ul>
                </div>
                <div class="widget widget-archives">
                    <h3 class="widget-title">归档</h3>
                    <ul>
                        {% for date in dateList %}
                            <li>
                                <a style="text-decoration:none; color:#404040" href="/wiki/archive/{{date.cdate}}">
                                    {{ date.cdate }} ({{ date.count }})</a>
                            </li>
                        {% empty %}
                            暂无归档！
                        {% endfor %}
                    </ul>
                </div>

                <div class="widget widget-category">
                    <h3 class="widget-title">分类</h3>
                    <ul>
                        {% for category in categoryList %}
                            <li>
                                <a style="text-decoration:none; color:#404040" href="/wiki/category/{{ category.id }}">{{ category.name }} <span
                                        class="post-count">({{ category.post_count }})</span></a>
                            </li>
                        {% empty %}
                            暂无分类！
                        {% endfor %}
                    </ul>
                </div>

                <div class="widget widget-tag-cloud">
                    <h3 class="widget-title">标签云</h3>
                    <ul class="list-unstyled list-inline">
                        {% for tag in tagList %}
                            <li>
                                <a style="text-decoration:none; color:#404040" href="/wiki/tag/{{tag.id}}">{{ tag.name }}</a>
                            </li>
                        {% empty %}
                            暂无标签！
                        {% endfor %}
                    </ul>
                </div>
                
            </div>         
        </div>
</div>
</div>
<script type="text/javascript">
{% if errorInfo %}
	window.wxc.xcConfirm("{{errorInfo}}", window.wxc.xcConfirm.typeEnum.error);
{% endif %}

	function delWikiData(obj,id){
		var txt=  "是否确认删除？";
		var btnObj = $(obj);
		btnObj.attr('disabled',true);
		var option = {
			title: "删除当前文章",
			btn: parseInt("0011",2),
			onOk: function(){
				$.ajax({
					  type: 'DELETE',
					  url: '/api/wiki/archive/'+id+'/',
				      success:function(response){	
				    	btnObj.removeAttr('disabled');
			            window.wxc.xcConfirm("删除成功", window.wxc.xcConfirm.typeEnum.success);
			            window.location.href='/wiki/index/'
				      },
		              error:function(response){
		            	btnObj.removeAttr('disabled');
		            	window.wxc.xcConfirm("删除失败！", window.wxc.xcConfirm.typeEnum.error);	
		              }
					});
			},
			onCancel:function(){	
			},
			onClose:function(){
			}
		}
		window.wxc.xcConfirm(txt, "custom", option);			   
	}
</script>
{% endblock %}